<template>
  <view class="template-product tn-safe-area-inset-bottom">
    <!-- 顶部自定义导航 -->
     <tn-nav-bar :isBack="true" backgroundColor="#4169E1" class="tatils">商品详情</tn-nav-bar>
    
    <swiper class="card-swiper" :circular="true"
      :autoplay="true" duration="500" interval="5000" @change="cardSwiper"> 
      <swiper-item v-for="(item,index) in winfo.imagelist" :key="index" :class="cardCur==index?'cur':''">
        <view class="swiper-item image-banner">
          <image :src="item" mode="aspectFill"></image>
        </view>
      </swiper-item>
    </swiper>
    <view class="indication">
        <block v-for="(item,index) in winfo.imagelist" :key="index">
            <view class="spot" :class="cardCur==index?'active':''"></view>
        </block>
    </view>
    <view class="tn-margin">
      <view class="tn-flex tn-flex-row-between">
        <view class="justify-content-item tn-text-bold tn-text-xxl">
          {{winfo.title}}
        </view>
      </view>
      <view class="tn-flex tn-flex-row-between tn-margin-top">
        <view class="justify-content-item tn-text-bold tn-color-purplered">
          <text class="" style="font-size: 50rpx;">{{winfo.num}}</text>
          <text class="tn-text-sm">￥</text>
        </view>
        <view class="justify-content-item tn-color-gray tn-padding-top-xs">
          <view class="">浏览 {{winfo.konum}}</view>
        </view>
      </view>
    </view>
    
    <!-- 边距间隔 -->
    <view class="tn-strip-bottom"></view>
    
    
    <!-- 更多信息-->
    <view class="tn-padding-top-sm tn-padding-bottom-sm">
      <tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="34">
        <view class="tn-flex tn-flex-col-center">
          <view class="tn-flex-1">分类</view>
          <view class="tn-margin-left-sm" style="font-size: 28rpx;">{{winfo.cname}}</view>
        </view>
      </tn-list-cell>
     <!-- <tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="34">
        <view class="tn-flex tn-flex-col-center">
          <view class="tn-flex-1">活动人数</view>
          <view class="tn-margin-left-sm" style="font-size: 28rpx;">129人</view>
        </view>
      </tn-list-cell>
      <tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="34">
        <view class="tn-flex tn-flex-col-center">
          <view class="tn-flex-1">活动时长</view>
          <view class="tn-margin-left-sm" style="font-size: 28rpx;">90天</view>
        </view>
      </tn-list-cell> -->
    </view>
	
	<view class="edit tnxuanfu" @tap="showLandscape">
	  <view class="bg0 pa">
	    <view class="bg1">
	      <image src="https://cstow.hephp.cn/uploads/20240623/fb36f13601085fd1dc3046c4eac32e09.gif" class="button-shop shadow"></image>
	    </view>
	  </view>
	  <view class="hx-box pa">
	    <view class="pr">
	      <view class="hx-k1 pa0">
	        <view class="span"></view>
	      </view>
	      <view class="hx-k2 pa0">
	        <view class="span"></view>
	      </view>
	      <view class="hx-k3 pa0">
	        <view class="span"></view>
	      </view>
	      <view class="hx-k4 pa0">
	        <view class="span"></view>
	      </view>
	      <view class="hx-k5 pa0">
	        <view class="span"></view>
	      </view>
	      <view class="hx-k6 pa0">
	        <view class="span"></view>
	      </view>
	    </view>
	  </view>
	</view>
	    
    <!-- 边距间隔 -->
    <view class="tn-strip-bottom"></view>
    <view class="footerfixed dd-glass tn-padding-left-sm tn-padding-right tn-padding-top-xs tn-padding-bottom-sm">
      <tn-goods-nav :options="countOptions" :buttonGroups="customButtonGroups" buttonType="round" :safeAreaInsetBottom="true" @optionClick="onOptionClick" @buttonClick="onButtonClick"></tn-goods-nav>
    </view>
    <view class='tn-tabbar-height'></view>
	<tn-popup v-model="show" mode="bottom" length="36%" closeBtn>
	      <view style="padding: 10px;width: 100%;margin-top: 20px;">
			  <view style="font-size: 18px;font-weight: 600;"> {{winfo.title}}</view>
			  <view style="overflow: hidden;margin-top: 30px;">
				  <view style="width: 50%;float: left;font-size: 18px;color: #4169E1;">单价:{{winfo.num}}</view>
				  <view style="width: 50%;float: left;text-align: right;">
					    <tn-number-box :min="1" :max="100" v-model="num" @change="djchange"></tn-number-box>
				  </view>
			  </view>
			  <view @click="addgwcs" style="width: 200px;margin: 0 auto;margin-top: 40px;
			  text-align: center;height: 30px;line-height: 30px;border-radius: 10px;background-color: #4169E1;color: #fff;">加入购物车</view>
		  </view>
	    </tn-popup>	
	<tn-popup v-model="showxd" mode="bottom" length="36%" closeBtn>
	  <view style="padding: 10px;width: 100%;margin-top: 20px;">
		  <view style="font-size: 18px;font-weight: 600;"> {{winfo.title}}</view>
		  <view style="overflow: hidden;margin-top: 30px;">
			  <view style="width: 50%;float: left;font-size: 18px;color: #4169E1;">单价:{{pic}}</view>
			  <view style="width: 50%;float: left;text-align: right;">
					<tn-number-box :min="1" :max="100" v-model="num" @change="djchange"></tn-number-box>
			  </view>
		  </view>
		  <view @click="addorders" style="width: 200px;margin: 0 auto;margin-top: 40px;
		  text-align: center;height: 30px;line-height: 30px;border-radius: 10px;
		  background-color: #4169E1;color: #fff;">立即下单</view>
	  </view>
	</tn-popup>	
  </view>
</template>

<script>
	import {
		getbanList,getgoodsList,getListdetail,addgwc
	} from '@/apis/sc.js'
  import request from '@/request/request.js';
  import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
  export default {
    name: 'TemplateProduct',
    mixins: [template_page_mixin],
    data(){
      return {
		show:false,
		showxd:false,
        cardCur: 0,
        swiperList: [],
        current: 0,
		pic:0,
		num:1,
		winfo:'',
		countOptions: [],
        customButtonGroups: [{
          text: '加入购物车',
          backgroundColor: 'tn-cool-bg-color-5',
          color: '#FFFFFF'
        },{
          text: '立即购买',
          backgroundColor: 'tn-cool-bg-color-15--reverse',
          color: '#FFFFFF'
        }],
		}
    },
	onLoad(opent) {
		this.getListdetails(opent.id)
	},
    methods: {
		djchange(e){
			console.log(e)
			this.pic  = this.num*this.winfo.num
		},
		addorders(){
			let data = {
				id:this.winfo.id,
				num:this.num,
				pic:this.pic,
				djpic:this.winfo.num,
				lxtype:1
			}
			uni.navigateTo({
				url:'/pages/mine/paydetail?id='+this.winfo.id+'&num='+this.num+'&lxtype=1'
			})
		
		},
		onButtonClick(e){
			if(e.index==0){
				//加入购物车
				this.show = true
			}else{
				this.showxd = true
			}
		},
		addgwcs(){
			let data = {
				num:this.num,
				uid:uni.getStorageSync('uid'),
				oid:this.winfo.id,
				pic:this.winfo.num,
				uid: uni.getStorageSync('uid')
			}
			addgwc(data).then(res => {
				if (res.code == 200) {
					this.show = false
					this.num = 1
					this.tool.toastTip('加入完成', 'none', 1000)
				}else{
					this.tool.toastTip('加入失败', 'none', 1000)
				}
			}).catch(error => {
				that.tool.toastTip('登录出错,请稍后重试!', 'none', 1000)
			})
		},
		
		showLandscape(){
			uni.navigateTo({
				url:'/pages/mine/bay'
			})
		},
		getListdetails(e){
			getListdetail({id:e}).then(res => {
			if (res.code == 200) {
				this.winfo = res.data
				this.pic = res.data.num*1
			}
			}).catch(error => {
				that.tool.toastTip('登录出错,请稍后重试!', 'none', 1000)
			})
		},
      // cardSwiper
      cardSwiper(e) {
        this.cardCur = e.detail.current
      },
      // 跳转
      tn(e) {
      	uni.navigateTo({
      		url: e,
      	});
      },
      // tab选项卡切换
      tabChange(index) {
        this.current = index
      },
      getRandomCoolBg() {
        return this.$t.colorUtils.getRandomCoolBgClass()
      }
    }
  }
</script>

<style lang="scss" scoped>
	/* 悬浮 */
	.tnxuanfu{
	  animation: suspension 3s ease-in-out infinite;
	}
	
	.pa,
	.pa0 {
	  position: absolute
	}
	
	.pa0 {
	  left: 0;
	  top: 0
	}
	
	
	.bg0 {
	  width: 100rpx;
	  height: 100rpx;
	  top: 50%;
	  left: 50%;
	  transform: translate(-50%, -50%);
	}
	
	.bg1 {
	  width: 100%;
	  height: 100%;
	}
	@keyframes suspension {
	  0%, 100% {
	    transform: translateY(0);
	  }
	  50% {
	    transform: translateY(-0.8rem);
	  }
	}
	/* 悬浮按钮 */
	.button-shop {
	  width: 90rpx;
	  height: 90rpx;
	  display: flex;
	  flex-direction: row;
	  position: fixed;
	  /* bottom:200rpx;
	    right: 20rpx; */
	  left: 5rpx;
	  top: 5rpx;
	  z-index: 1001;
	  border-radius: 100px;
	  opacity: 0.9;
	}
	
	
	.hx-box {
	  top: 50%;
	  left: 50%;
	  width: 100rpx;
	  height: 100rpx;
	  transform-style: preserve-3d;
	  transform: translate(-50%, -50%) rotateY(75deg) rotateZ(10deg);
	}
	
	.hx-box .pr {
	  width: 100rpx;
	  height: 100rpx;
	  transform-style: preserve-3d;
	  animation: hxz 20s linear infinite;
	}
	
	@keyframes hxz {
	  0% {
	    transform: rotateX(0deg);
	  }
	
	  100% {
	    transform: rotateX(-360deg);
	  }
	}
	
	
	
	.hx-box .pr .pa0 {
	  width: 100rpx;
	  height: 100rpx;
	  /* border: 4px solid #5ec0ff; */
	  border-radius: 1000px;
	}
	
	.hx-box .pr .pa0 .span {
	  display: block;
	  width: 100%;
	  height: 100%;
	  background: url(https://resource.tuniaokj.com/images/cool_bg_image/arc4.png) no-repeat center center;
	  background-size: 100% 100%;
	  animation: hx 4s linear infinite;
	}
	
	@keyframes hx {
	  to {
	    transform: rotate(360deg);
	  }
	}
	
	.hx-k1 {
	  transform: rotateX(-60deg) rotateZ(-60deg)
	}
	
	.hx-k2 {
	  transform: rotateX(-30deg) rotateZ(-30deg)
	}
	
	.hx-k3 {
	  transform: rotateX(0deg) rotateZ(0deg)
	}
	
	.hx-k4 {
	  transform: rotateX(30deg) rotateZ(30deg)
	}
	
	.hx-k5 {
	  transform: rotateX(60deg) rotateZ(60deg)
	}
	
	.hx-k6 {
	  transform: rotateX(90deg) rotateZ(90deg)
	}
	/* 按钮 */
	.edit {
	  bottom: 300rpx;
	  right: 75rpx;
	  position: fixed;
	  z-index: 9999;
	}
  .template-product{
  }
  .tn-tabbar-height {
  	min-height: 120rpx;
  	height: calc(140rpx + env(safe-area-inset-bottom) / 2);
  }
  .tatils {
  	color: #fff;
  }
  /* 用户头像 start */
  .logo-image {
    width: 110rpx;
    height: 110rpx;
    position: relative;
  }
  
  .logo-pic {
    background-size: cover;
    background-repeat: no-repeat;
    // background-attachment:fixed;
    background-position: top;
    box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
    border-radius: 10rpx;
    overflow: hidden;
    // background-color: #FFFFFF;
  }
  
  /* 胶囊*/
  .tn-custom-nav-bar__back {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 1000rpx;
    border: 1rpx solid rgba(255, 255, 255, 0.5);
    color: #FFFFFF;
    font-size: 18px;
    
    .icon {
      display: block;
      flex: 1;
      margin: auto;
      text-align: center;
    }
    
    &:before {
      content: " ";
      width: 1rpx;
      height: 110%;
      position: absolute;
      top: 22.5%;
      left: 0;
      right: 0;
      margin: auto;
      transform: scale(0.5);
      transform-origin: 0 0;
      pointer-events: none;
      box-sizing: border-box;
      opacity: 0.7;
      background-color: #FFFFFF;
    }
  }
  
  /* 轮播视觉差 start */
  .card-swiper {
    height: 750rpx !important;
  }
    
  .card-swiper swiper-item {
    width: 750rpx !important;
    left: 0rpx;
    box-sizing: border-box;
    // padding: 0rpx 30rpx 90rpx 30rpx;
    overflow: initial;
  }
    
  .card-swiper swiper-item .swiper-item {
    width: 100%;
    display: block;
    height: 100%;
    transform: scale(1);
    transition: all 0.2s ease-in 0s;
    overflow: hidden;
  }
    
  .card-swiper swiper-item.cur .swiper-item {
    transform: none;
    transition: all 0.2s ease-in 0s;
  }
  
  .image-banner{
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .image-banner image{
    width: 100%;
    height: 100%;
  }
  
  /* 轮播指示点 start*/
  .indication{
    z-index: 9999;
    width: 100%;
    height: 36rpx;
    position: absolute;
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:center;
  }
  
  .spot{
    background-color: #FFFFFF;
    opacity: 0.6;
    width: 10rpx;
    height: 10rpx;
    border-radius: 20rpx;
    top: -60rpx;
    margin: 0 8rpx !important;
    position: relative;
  }
  
  .spot.active{
    opacity: 1;
    width: 30rpx;
    background-color: #FFFFFF;
  }
  
  /* 间隔线 start*/
  .tn-strip-bottom-min {
    width: 100%;
    border-bottom: 1rpx solid #F8F9FB;
  }
  
  /* 间隔线 start*/
  .tn-strip-bottom {
   width: 100%;
   border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
  }
   /* 间隔线 end*/
  /* 标题 start */
  .nav_title {
    -webkit-background-clip: text;
    color: transparent;
    
    &--wrap {
      position: relative;
      display: flex;
      height: 120rpx;
      font-size: 46rpx;
      align-items: center;
      justify-content: center;
      font-weight: bold;
      background-image: url(https://resource.tuniaokj.com/images/title_bg/title44.png);
      background-size: cover;
    }
  }
  /* 标题 end */
  
  /* 底部tabbar start*/
  .footerfixed{
   position: fixed;
   width: 100%;
   bottom: 0;
   z-index: 999;
   background-color: #FFFFFF;
   box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
  }
  
  /* 标签内容 start*/
  .tn-tag-content {
    &__item {
      display: inline-block;
      line-height: 45rpx;
      padding: 10rpx 30rpx;
      margin: 20rpx 20rpx 5rpx 0rpx;
      
      &--prefix {
        padding-right: 10rpx;
      }  
    }
  }
  /* 标签内容 end*/
  
  /* 内容图 start */
  .content-backgroup {
    z-index: -1;
  
    .backgroud-image {
      border-radius: 15rpx;
      width: 100%;
    }
  }
  /* 内容图 end */
  
  /* 商家商品 start*/
  .tn-blogger-content {
    &__wrap {
      box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
      border-radius: 20rpx;
      margin: 15rpx;
    }
    
    &__info {
      &__btn {
        margin-right: -12rpx;
        opacity: 0.5;
      }
    }
    
    &__label {
      &__item {
        line-height: 45rpx;
        padding: 0 10rpx;
        margin: 5rpx 18rpx 0 0;
        
        &--prefix {
          color: #E83A30;
          padding-right: 10rpx;
        }
      }
      
      &__desc {
        line-height: 35rpx;
      }
    }
    
    &__main-image {
      border-radius: 16rpx 16rpx 0 0;
      
      &--1 {
        max-width: 690rpx;
        min-width: 690rpx;
        max-height: 400rpx;
        min-height: 400rpx;
      }
      
      &--2 {
        max-width: 260rpx;
        max-height: 260rpx;
      }
      
      &--3 {
        height: 212rpx;
        width: 100%;
      }
    }
    
    &__count-icon {
      font-size: 24rpx;
      padding-right: 5rpx;
    }
  }
  
  .image-book{
    padding: 150rpx 0rpx;
    font-size: 16rpx;
    font-weight: 300;
    position: relative;
  }
  .image-picbook{
    background-size: cover;
    background-repeat:no-repeat;
    // background-attachment:fixed;
    background-position:top;
    border-radius: 15rpx 15rpx 0 0;
  }
  
  /* 毛玻璃*/
  .dd-glass {
     width: 100%;
     backdrop-filter: blur(20rpx);
    -webkit-backdrop-filter: blur(20rpx);
  }
</style>
